﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminIndexMaster.master" AutoEventWireup="true" CodeFile="Admin_ShopCity.aspx.cs" Inherits="Admin_Admin_ShopCity" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
	<script src="../Skin/CommStyle/js/jquery-1.8.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
	var c;
	function cc(obj) {
		c = obj.style.backgroundColor;
		obj.style.backgroundColor = '#E7EDFE';
	}
	function cc1(obj) {
		obj.style.backgroundColor = c;
	}

	function GetCity(selectVal) {
		if (selectVal == "手工输入") {
			//$("#ctl00_ContentPlaceHolder1_TxtProvince").css("display", "block");
			$("#SelectCity").html("<option value=''>请选择...</option>");
			$("#SelectArea").html("<option value=''>请选择...</option>");
			$("#SelectTown").html("<option value=''>请选择...</option>");
			$("#ctl00_ContentPlaceHolder1_TxtProvince").focus();
			//            $("#SelectCity").css("display", "none");
			//            $("#SelectArea").css("display", "none");
			//            $("#SelectTown").css("display", "none");
			return;
		}
		if (selectVal == "") {
			//$("#ctl00_ContentPlaceHolder1_TxtProvince").css("display", "none");
			$("#SelectCity").html("<option value=''>请选择...</option>");
			$("#SelectArea").html("<option value=''>请选择...</option>");
			$("#SelectTown").html("<option value=''>请选择...</option>");
			//            $("#SelectCity").css("display", "none");
			//            $("#SelectArea").css("display", "none");
			//            $("#SelectTown").css("display", "none");
			return;
		}
		//$("#ctl00_ContentPlaceHolder1_TxtProvince").css("display", "none");
		$.post("../WebService/ShopService.ashx", { 'Action': 'GetCity', 'Province': selectVal },
				function (data, state) {
					if (state == "success") {
						if (data.length > 1) {
							var city = data.split("|");
							var str = "<option value=''>请选择...</option>";
							for (i = 0; i < city.length; i++) {
								str += "<option value='" + city[i] + "'>" + city[i] + "</option>";
							}
							str += "<option value='手工输入'>手工输入</option>";
							$("#SelectCity").html(str);
							$("#SelectCity").css("display", "block");
							$("#SelectArea").css("display", "none");
							$("#SelectTown").css("display", "none");
						}
					}
				});
	}

	function GetAreaOrTown(selectCity) {
		if (selectCity == "手工输入") {
			$("#SelectArea").html("<option value=''>请选择...</option>");
			$("#SelectTown").html("<option value=''>请选择...</option>");
			$("#SelectCity").focus();
			return;
		}
		//$("#SelectArea").css("display", "none");
		//$("#SelectTown").css("display", "none");
		if (selectCity == "") {
			$("#SelectArea").html("<option value=''>请选择...</option>");
			$("#SelectTown").html("<option value=''>请选择...</option>");
			return;
		}
		$("#ctl00_ContentPlaceHolder1_HFselectCity").val(selectCity);
		//                $("#ctl00_ContentPlaceHolder1_TxtCity").css("display", "none");
		$.post("../WebService/ShopService.ashx", { 'Action': 'GetAreaOrTown', 'City': selectCity },
				function (data, state) {
					if (state == "success") {
						if (data.length > 1) {
							var AreaOrTown = data.split("||");
							var strArea = "<option value=''>请选择...</option>";
							var strTown = "<option value=''>请选择...</option>";
							if (AreaOrTown[0].length > 1) {
								var allArea = AreaOrTown[0].split("|");
								for (i = 0; i < allArea.length; i++) {
									strArea += "<option value='" + allArea[i] + "'>" + allArea[i] + "</option>";
								}
								strArea += "<option value='手工输入'>手工输入</option>";
								//$("#SelectArea").css("display", "block");

							}
							if (AreaOrTown[1].length > 1) {
								var allTown = AreaOrTown[1].split("|");
								for (i = 0; i < allTown.length; i++) {
									strTown += "<option value='" + allTown[i] + "'>" + allTown[i] + "</option>";
								}
								strTown += "<option value='手工输入'>手工输入</option>";
								//$("#SelectTown").css("display", "block");
							}

							$("#SelectArea").html(strArea);
							$("#SelectTown").html(strTown);

						}
					}
				});
	}

	function SelectAreaOrTown(selectval, num) {
		if (selectval == "手工输入") {
			if (num == 1) {
				$("#ctl00_ContentPlaceHolder1_txtArea").focus();
			}
			else if (num == 0) {
				$("#ctl00_ContentPlaceHolder1_txtTown").focus();
			}
			return;
		}
		//                if (num == 1) {

		//                    if (selectval == "") {
		//                        $("#ctl00_ContentPlaceHolder1_txtArea").css("display", "block");
		//                    } else {
		//                        $("#ctl00_ContentPlaceHolder1_txtArea").css("display", "none");
		//                    }
		//                } else if (num == 0) {
		//                    if (selectval == "") {
		//                        $("#ctl00_ContentPlaceHolder1_txtTown").css("display", "block");
		//                    } else {
		//                        $("#ctl00_ContentPlaceHolder1_txtTown").css("display", "none");
		//                    }
		//                 }
	}
</script>

<table class="" width="98%">
   <tr>
	 <th align="left">地区管理</th>   
	 <td align="right">
	 <div style="float:right; margin:5px 0 0 5px">
	<asp:ImageButton ID="Button3" runat="server" OnClick="Button3_Click" CausesValidation="false" ImageUrl="Images/addcity.png" />
	 </div>
	 <asp:Panel runat="server" ID ="Panelheand"  style="float:right;">
			 快速查找省份：<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True"
			 AutoPostBack="True" DataSourceID="ObjectDataSource2" DataTextField="Province"
			 DataValueField="Province">
			 <asp:ListItem>所有</asp:ListItem>
	 </asp:DropDownList>
	 <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="GetAllProvince"  TypeName="HKB.Web.Shop_City"/>
	 </asp:Panel>
	 </td>
   </tr>
</table>

  <asp:Panel runat="server" ID ="Pannel1">
		<asp:GridView id="GridView1" runat="server" DataSourceID="ObjectDataSource1" AutoGenerateColumns="False" DataKeyNames="ID" CssClass="adminlist" AllowPaging="True" PageSize="20"  OnDataBound="GridView1_DataBound">
		<Columns>
		<asp:BoundField DataField="Province" HeaderText="省份"></asp:BoundField>
		<asp:BoundField DataField="City" HeaderText="城市"></asp:BoundField>
		<asp:BoundField DataField="Area" HeaderText="区/县"></asp:BoundField>
		<asp:BoundField DataField="Town" HeaderText="镇"></asp:BoundField>
		<asp:CheckBoxField DataField="Flag" HeaderText="<a href='#' title='只有标记了的城市才会在商品分类列表地区下拉框中显示。'><font style='color:#1D8197'>标记为重点城市</font></a>"></asp:CheckBoxField>
		<asp:TemplateField HeaderText="删除">
		  <ItemTemplate>
			<asp:LinkButton ID="mod" runat="server" CommandName="edit" Text="编辑" />
			<asp:LinkButton ID="cl" runat="server" CommandName="Delete" OnClientClick="if(confirm('确定删除吗？'))return true; return false;" Text="删除" />
		  </ItemTemplate>
		  <EditItemTemplate>
			<asp:LinkButton ID="modi" runat="server" CommandName="Update" Text="提交" />
			<asp:LinkButton ID="cl" runat="server" CommandName="Cancel" Text="取消" />
		  </EditItemTemplate>
		</asp:TemplateField>
		</Columns>
		<EmptyDataTemplate>
			<tr>
			<th>省份</th><th>城市</th><th>区/县</th><th>镇</th><th>标记</th><th>删除</th><th scope="col">编辑</th>
			</tr>
			<tr><td colspan="5">暂无信息！</td></tr> 
		</EmptyDataTemplate> 
		</asp:GridView> 

	
	
	<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="DeleteCity"
		InsertMethod="AddCity" SelectMethod="GetCity" TypeName="HKB.Web.Shop_City" UpdateMethod="UpdateCity">
		<DeleteParameters>
			<asp:Parameter Name="ID" Type="Int32" />
		</DeleteParameters>
		<UpdateParameters>
			<asp:Parameter Name="Province" Type="String" />
			<asp:Parameter Name="City" Type="String" />
			 <asp:Parameter Name="Area" Type="String" />
			   <asp:Parameter Name="Town" Type="String" />
			<asp:Parameter Name="Flag" Type="Boolean" />
			<asp:Parameter Name="ID" Type="Int32" />
		</UpdateParameters>
		<SelectParameters>
			<asp:ControlParameter ControlID="DropDownList1" Name="Province" PropertyName="SelectedValue"
				Type="String" />
		</SelectParameters>
		<InsertParameters>
			<asp:Parameter Name="Province" Type="String" />
			<asp:Parameter Name="City" Type="String" />
			 <asp:Parameter Name="Area" Type="String" />
			  <asp:Parameter Name="Town" Type="String" />
			<asp:Parameter Name="Flag" Type="Boolean" />
		</InsertParameters>
	</asp:ObjectDataSource>

	<div class="help_intro" >
	<h1>帮助说明：</h1>
		<ul>
		  <li>注意：地区跟商品所在地和店铺所在地相关联，非必要情况请不要编辑名称或删除。</li></ul>                       
	</div>
	
</asp:Panel> 

 <asp:Panel runat="server" ID="panneladd" Visible="False">
   <table class="nick" cellpadding="1" cellspacing="1" border="0">
		<tr>
			 <td class="tit" colspan="2">新添地区</td>
		</tr>
		<tr class="tdbg">
			<td class="ltd">省份：</td>
			<td class="rtd">
				<input id="TxtProvince" maxlength="10" name="UserName" size="30" runat="server" />
				<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TxtProvince"
					ErrorMessage="省份名称不能空"></asp:RequiredFieldValidator></td>
		</tr>
		<tr>
			<td class="ltd">城市：</td>
			<td class="rtd">
				<input id="TxtCity" 　 maxlength="10" name="Balance" size="30" runat="server" />
				<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TxtCity"
					ErrorMessage="城市名称不能空"></asp:RequiredFieldValidator></td>
		</tr>
		<tr>
			<td class="ltd">重点城市标记：</td>
			<td class="rtd">
				<asp:CheckBox ID="chFlag" runat="server" /></td>
		</tr>
		<tr>
			<td class="btm" colspan="2">
			<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="保存" />
			<asp:Button ID="Button1" runat="server" Text="返回" CausesValidation="False" OnClick="Button1_Click" />
		</td>
		</tr>
	</table>     
  </asp:Panel> 

</asp:Content>